package com.ling.pl.security.model;

import com.ling.pl.core.commons.constant.TablePreDef;
import com.ling.pl.core.model.impl.BaseEntity;
import org.apache.commons.collections.ListUtils;

import javax.persistence.*;
import java.util.List;

/**
 * 分组信息
 * 人,组织,岗位
 *
 * @author bo.wang
 * @version 2.0.0
 * @create 2016年3月15日 下午1:38:01
 */
@Entity
@Table(name = DefaultGroup.TABLE)
public class DefaultGroup extends BaseEntity {

    public static final String TABLE = TablePreDef.BASEPRE + "GROUP";
    public static final String SEQ = TABLE;

    @Id
    @Column(name = "GROUP_ID", length = 36)
    String id;

    @Column(name = "NAME", length = 60)
    String name;

    @Column(name = "DESCRIPTION", length = 120)
    String desc;

    @Column(name = "PARENT_ID", length = 36)
    String parentId;

    @Transient
    private List<DefaultUser> users;

    @Transient
    private List<DefaultOrg> orgs;

    @Transient
    private List<DefaultPosition> positions;

    public DefaultGroup() {

    }

    public DefaultGroup(String groupId) {
        this.id = groupId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    @SuppressWarnings("unchecked")
    public List<DefaultUser> getUsers() {
        if (users == null) {
            return ListUtils.EMPTY_LIST;
        }
        return users;
    }

    public void setUsers(List<DefaultUser> users) {
        this.users = users;
    }

    @SuppressWarnings("unchecked")
    public List<DefaultOrg> getOrgs() {
        if (orgs == null) {
            return ListUtils.EMPTY_LIST;
        }
        return orgs;
    }

    public void setOrgs(List<DefaultOrg> orgs) {
        this.orgs = orgs;
    }

    @SuppressWarnings("unchecked")
    public List<DefaultPosition> getPositions() {
        if (positions == null) {
            return ListUtils.EMPTY_LIST;
        }
        return positions;
    }

    public void setPositions(List<DefaultPosition> positions) {
        this.positions = positions;
    }

}
